package com.example.diethealthsystem.service;

import com.example.diethealthsystem.entity.HealthGoal;
import com.example.diethealthsystem.repository.HealthGoalRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class HealthGoalService {

    private final HealthGoalRepository healthGoalRepository;

    @Autowired
    public HealthGoalService(HealthGoalRepository healthGoalRepository) {
        this.healthGoalRepository = healthGoalRepository;
    }

    public List<HealthGoal> findAll() {
        return healthGoalRepository.findAll();
    }

    public Optional<HealthGoal> findById(Long id) {
        return healthGoalRepository.findById(id);
    }

    public HealthGoal save(HealthGoal healthGoal) {
        return healthGoalRepository.save(healthGoal);
    }

    public void deleteById(Long id) {
        healthGoalRepository.deleteById(id);
    }

    public List<HealthGoal> findByUserId(Long userId) {
        return healthGoalRepository.findByUserId(userId);
    }
} 